from game import zz_game
from zz import zz_log, zz_img

log = zz_log.of()


class Game(zz_game.ZZ_Game):
    def __init__(self, d, has_prize=True):
        super().__init__(d, has_prize)

    def get_name(self):
        return "傲视苍穹"

    def game_alert(self):
        self.alert_close_by_file('./game/img/傲视苍穹')

    def handle_main(self):
        self.log_msg("等待进入游戏")
        self.img_exit('./game/img/傲视苍穹/game_main00.png', 100)
        self.log_msg("已进入游戏界面")
        self.game_alert()
        #
        if self.not_prize_handle():
            return False
        #
        self.img_click_if_exists("点击开始游戏", './game/img/傲视苍穹/game_start.png', './game/img/傲视苍穹/game_go.png')
        self.log_msg("点击进入游戏")
        self.img_click('./game/img/傲视苍穹/game_go.png')
        self.log_msg("等待游戏主界面")
        self.img_exit('./game/img/傲视苍穹/game_main01.png', 100)
        self.log_msg("已进入游戏主界面")

        if self.img_exit('./game/img/傲视苍穹/game_alert.png', 5):
            self.log_msg("存在离线收益弹窗，进行关闭")
            self.img_click('./game/img/傲视苍穹/game_get.png')

        self.img_click_if_exists("点击背包", './game/img/傲视苍穹/box.png', './game/img/傲视苍穹/box01.png')
        self.img_click_if_exists("点击回收", './game/img/傲视苍穹/box01.png', './game/img/傲视苍穹/box_get.png')
        self.log_msg("勾选极品装备")
        self.img_click('./game/img/傲视苍穹/box_get.png')
        self.img_click_if_exists("点击一键回收", './game/img/傲视苍穹/box_get01.png', './game/img/傲视苍穹/box_get_alert.png')
        self.log_msg("点击确定")
        self.img_click('./game/img/傲视苍穹/box_get02.png')

        return True
